package per.jdz.demo.listener;

import com.mybatisflex.annotation.InsertListener;
import com.mybatisflex.annotation.UpdateListener;
import per.jdz.demo.domain.entity.OriginLandData;
import per.jdz.demo.utils.Md5Utils;

/**
 * @author Jdz
 * @date 2025/2/6
 */
public class LandUpsertListener implements InsertListener, UpdateListener {
    @Override
    public void onInsert(Object o) {
        hashValue((OriginLandData) o);
    }

    @Override
    public void onUpdate(Object o) {
        hashValue((OriginLandData) o);
    }

    public void hashValue(OriginLandData landData) {
        String city = landData.getCity();
        String landName = landData.getLandName();
        String t = city + landName;
        landData.setHashValue(Md5Utils.hash(t));
    }
}
